package com.example.zhilongzhang.constructionpayapp.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.example.zhilongzhang.constructionpayapp.R;
import com.example.zhilongzhang.constructionpayapp.base.BaseActivity;
import com.example.zhilongzhang.constructionpayapp.base.ToastManager;

public class RigisterActivity extends BaseActivity {
    EditText edPhone,edCode,edId,edPass,edPass2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rigister);
        edPhone=findViewById(R.id.ed_phone);
        edCode=findViewById(R.id.ed_code);
        edId=findViewById(R.id.ed_id);
        edPass=findViewById(R.id.ed_pass);
        edPass2=findViewById(R.id.ed_pass2);
        initData();


    }
    private void initData(){
        findViewById(R.id.tv_register).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (TextUtils.isEmpty(edPhone.getText().toString())){
                    ToastManager.getInstance(RigisterActivity.this).showToast("请输入手机号");
                    return;
                }
                /*if (TextUtils.isEmpty(edCode.getText())){
                    ToastManager.getInstance(RigisterActivity.this).showToast("请输入验证码");
                    return;
                }*/
                if (TextUtils.isEmpty(edId.getText().toString())){
                    ToastManager.getInstance(RigisterActivity.this).showToast("请输入商户ID");
                    return;
                }
                if (TextUtils.isEmpty(edPass.getText().toString().trim())){
                    ToastManager.getInstance(RigisterActivity.this).showToast("请输入密码");
                    return;
                }
                if (TextUtils.isEmpty(edPass2.getText().toString().trim())){
                    ToastManager.getInstance(RigisterActivity.this).showToast("请再输一次密码");
                    return;
                }
                if (!TextUtils.equals(edPass.getText().toString(), edPass2.getText().toString())){
                    ToastManager.getInstance(RigisterActivity.this).showToast("两次密码不一样,请重新输入");
                    return;
                }
                finish();
            }
        });
        findViewById(R.id.left).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        findViewById(R.id.cancel_phone).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                edPhone.setText("");
            }
        });
        findViewById(R.id.get_code).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        findViewById(R.id.cancel_id).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                edId.setText("");
            }
        });
        findViewById(R.id.cancel_pass).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                edPass.setText("");
            }
        });
        findViewById(R.id.cancel_pass2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                edPass2.setText("");
            }
        });
    }
}
